<?php
namespace app\modules\adminapi\controllers;

use fate\http\Request;
use app\models\UserCredit;
use app\libs\Util;

class EditusercreditController extends \app\modules\adminapi\ForceLoginPure {

    public function run() {
        global $_G;

        $req = Request::getInstance();

        $id = $req->getParameter('id');
        $uid = $req->getParameter('uid');
        $score = $req->getParameter('score');
        $money = $req->getParameter('money');
        $experience = $req->getParameter('experience');

        if(!is_numeric($id) || !is_numeric($uid)
            || !is_numeric($score) || !is_numeric($money)
            || !is_numeric($experience)) {
            $this->ajaxReturn(null, 300002);
            exit;
        }

        $data = [
            'money' => $money,
            'score' => $score,
            'experience' => $experience
        ];
        // var_dump($data);exit;

        $model = new UserCredit();
        $ret = $model->update($id, $data);

        $this->ajaxReturn(null);
    }

}
